home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / System / ReqToolsLib / Source / reqtools / reqtools_init.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-02  |  5.6 KB  |  229 lines

  1. /*
  2.     (C) 1999 - 2001 AROS - The Amiga Research OS
  3.     $Id: reqtools_init.c,v 1.7 2001/06/29 16:38:48 stegerg Exp $
  4.  
  5.     Desc: ReqTools initialization code.
  6.     Lang: English.
  7. */
  8.  
  9. /****************************************************************************************/
  10.  
  11. #define  AROS_ALMOST_COMPATIBLE
  12.  
  13. #include "reqtools_intern.h"
  14. #include <exec/types.h>
  15. #include <exec/resident.h>
  16. #include <dos/dos.h>
  17. #include <intuition/intuition.h>
  18. #include <devices/conunit.h>
  19. #include <utility/utility.h>
  20. #include <proto/exec.h>
  21. #include <proto/dos.h>
  22. #include <proto/intuition.h>
  23. #include <intuition/classes.h>
  24. #include <libraries/reqtools.h>
  25. #include <aros/libcall.h>
  26. #include <aros/asmcall.h>
  27. #include <aros/macros.h>
  28.  
  29. #include "initstruct.h"
  30. #include <stddef.h>
  31. #include <string.h>
  32.  
  33. #define DEBUG 1
  34. #include <aros/debug.h>
  35.  
  36. #include <exec/libraries.h>
  37. #include <exec/alerts.h>
  38. #include "libdefs.h"
  39.  
  40. #include "general.h"
  41. #include "boopsigads.h"
  42. #include "rtfuncs.h"
  43.  
  44. /****************************************************************************************/
  45.  
  46. #define INIT    AROS_SLIB_ENTRY(init, ReqTools)
  47.  
  48. struct inittable;
  49. extern const char name[];
  50. extern const char version[];
  51. extern const APTR inittabl[4];
  52. extern void *const LIBFUNCTABLE[];
  53. extern const struct inittable datatable;
  54. extern struct IntReqToolsBase *INIT();
  55. extern struct IntReqToolsBase *AROS_SLIB_ENTRY(open, ReqTools)();
  56. extern BPTR AROS_SLIB_ENTRY(close, ReqTools)();
  57. extern BPTR AROS_SLIB_ENTRY(expunge, ReqTools)();
  58. extern int AROS_SLIB_ENTRY(null, ReqTools)();
  59. extern const char LIBEND;
  60.  
  61. /****************************************************************************************/
  62.  
  63. int entry(void)
  64. {
  65.     /* If the library was executed by accident return error code. */
  66.     return -1;
  67. }
  68.  
  69. /****************************************************************************************/
  70.  
  71. const struct Resident resident=
  72. {
  73.     RTC_MATCHWORD,
  74.     (struct Resident *)&resident,
  75.     (APTR)&LIBEND,
  76.     RTF_AUTOINIT,
  77.     VERSION_NUMBER,
  78.     NT_LIBRARY,
  79.     0,
  80.     (char *)name,
  81.     (char *)&version[6],
  82.     (ULONG *)inittabl
  83. };
  84.  
  85. const char name[] = NAME_STRING;
  86.  
  87. const char version[] = VERSION_STRING;
  88.  
  89. const APTR inittabl[4]=
  90. {
  91.     (APTR)sizeof(struct IntReqToolsBase),
  92.     (APTR)LIBFUNCTABLE,
  93.     (APTR)&datatable,
  94.     &INIT
  95. };
  96.  
  97. struct inittable
  98. {
  99.     S_CPYO(1,1,B);
  100.     S_CPYO(2,1,L);
  101.     S_CPYO(3,1,B);
  102.     S_CPYO(4,1,W);
  103.     S_CPYO(5,1,W);
  104.     S_CPYO(6,1,L);
  105.     S_END (LIBEND);
  106. };
  107.  
  108. #define O(n) offsetof(struct ReqToolsBase, n)
  109.  
  110. const struct inittable datatable=
  111. {
  112.     { { I_CPYO(1,B,O(LibNode.lib_Node.ln_Type)), { NT_LIBRARY } } },
  113.     { { I_CPYO(1,L,O(LibNode.lib_Node.ln_Name)), { (IPTR)name } } },
  114.     { { I_CPYO(1,B,O(LibNode.lib_Flags       )), { LIBF_SUMUSED|LIBF_CHANGED } } },
  115.     { { I_CPYO(1,W,O(LibNode.lib_Version     )), { 1 } } },
  116.     { { I_CPYO(1,W,O(LibNode.lib_Revision    )), { 0 } } },
  117.     { { I_CPYO(1,L,O(LibNode.lib_IdString    )), { (IPTR)&version[6] } } },
  118.     I_END ()
  119. };
  120.  
  121. #undef O
  122.  
  123. /****************************************************************************************/
  124.  
  125. /* Global variables */
  126.  
  127. #define extern
  128. #include "globalvars.h"
  129. #undef extern
  130.  
  131. /****************************************************************************************/
  132.  
  133. AROS_LH2(struct IntReqToolsBase *, init,
  134.  AROS_LHA(struct IntReqToolsBase *, RTBase, D0),
  135.  AROS_LHA(BPTR,               segList,   A0),
  136.        struct ExecBase *, sysBase, 0, ReqTools)
  137. {
  138.     AROS_LIBFUNC_INIT
  139.     
  140.     ReqToolsBase = (struct ReqToolsBase *)RTBase;
  141.         
  142.     /* This function is single-threaded by exec by calling Forbid. */
  143.  
  144.     RTBase->rt_SysBase = SysBase = sysBase;
  145.  
  146.     D(bug("reqtools.library: Inside libinit func\n"));
  147.     
  148.     return (struct IntReqToolsBase *)RTFuncs_Init(&RTBase->rt, segList);
  149.  
  150.     AROS_LIBFUNC_EXIT
  151. }
  152.  
  153. /****************************************************************************************/
  154.  
  155. AROS_LH1(struct IntReqToolsBase *, open,
  156.  AROS_LHA(ULONG, version, D0),
  157.        struct IntReqToolsBase *, RTBase, 1, ReqTools)
  158. {
  159.     AROS_LIBFUNC_INIT
  160.     
  161.     D(bug("reqtools.library: Inside libopen func\n"));
  162.  
  163.     /*
  164.       This function is single-threaded by exec by calling Forbid.
  165.       If you break the Forbid() another task may enter this function
  166.       at the same time. Take care.
  167.     */
  168.     
  169.     /* Keep compiler happy */
  170.     (void)version;
  171.  
  172.     D(bug("reqtools.library: Inside libopen func\n"));
  173.     
  174.     return (struct IntReqToolsBase *)RTFuncs_Open(&RTBase->rt, version);
  175.  
  176.     AROS_LIBFUNC_EXIT
  177. }
  178.  
  179. /****************************************************************************************/
  180.  
  181. AROS_LH0(BPTR, close, struct IntReqToolsBase *, RTBase, 2, ReqTools)
  182. {
  183.     AROS_LIBFUNC_INIT
  184.     /*
  185.     This function is single-threaded by exec by calling Forbid.
  186.     If you break the Forbid() another task may enter this function
  187.     at the same time. Take care.
  188.     */
  189.  
  190.     D(bug("reqtools.library: Inside libclose func.\n"));
  191.  
  192.     return RTFuncs_Close(&RTBase->rt);
  193.     
  194.     AROS_LIBFUNC_EXIT
  195. }
  196.  
  197. /****************************************************************************************/
  198.  
  199. AROS_LH0(BPTR, expunge, struct IntReqToolsBase *, RTBase, 3, ReqTools)
  200. {
  201.     AROS_LIBFUNC_INIT
  202.  
  203.     /*
  204.     This function is single-threaded by exec by calling Forbid.
  205.     Never break the Forbid() or strange things might happen.
  206.     */
  207.  
  208.     /* Test for openers. */
  209.  
  210.     D(bug("reqtools.library: Inside libexpunge func.\n"));
  211.  
  212.     return RTFuncs_Expunge(&RTBase->rt);
  213.     
  214.     AROS_LIBFUNC_EXIT
  215. }
  216.  
  217. /****************************************************************************************/
  218.  
  219. AROS_LH0(int, null, struct IntReqToolsBase *, RTBase, 4, ReqTools)
  220. {
  221.     AROS_LIBFUNC_INIT
  222.  
  223.     return RTFuncs_Null(&RTBase->rt);
  224.     
  225.     AROS_LIBFUNC_EXIT
  226. }
  227.  
  228. /****************************************************************************************/
  229.